package com.lz.old.compartor;

import java.util.Comparator;

public class CompartorDemo {

	public static void main(String[] args) {
		MyComparator myCoppartor = new MyComparator();
		A a1 = new A("lizhong", 18, 10);
		A a2 = new A("zhangsan", 50, 2);
		int compare = myCoppartor.compare(a1, a2);
		System.out.println(compare);
	}
}

class A {
	private String name;
	private Integer age;
	private long num;

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public Integer getAge() {
		return age;
	}

	public void setAge(Integer age) {
		this.age = age;
	}

	public long getNum() {
		return num;
	}

	public void setNum(long num) {
		this.num = num;
	}

	public A(String name, Integer age, long num) {
		super();
		this.name = name;
		this.age = age;
		this.num = num;
	}

}

class MyComparator implements Comparator<A> {

	@Override
	public int compare(A o1, A o2) {

		return o1.getAge().compareTo(o2.getAge());
	}

}
